# -*- coding:utf-8 -*-
import logging
import time


def pytest_collection_modifyitems(session, config, items:list):
    for item in items:
        # item.name:用例的名字，decode('unicode-escape')：解码
        item.name=item.name.encode('utf-8').decode('unicode-escape')
        # item.nodeid用例的路径
        item._nodeid=item.nodeid.encode('utf-8').decode('unicode-escape')

# 定义日志输出格式
fmt_str = '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s'
# 日志打印路径
now = time.strftime("%Y年%m月%d日 %H时%M分%S秒")
file_path='./log/'+now+'.txt'

# 打印日志
logging.basicConfig(level=logging.INFO,
                    format=fmt_str,
                    datefmt='%Y%m%d %H:%M:%S', # 日志时间格式
                    filename=file_path,
                    filemode='w')